﻿@using YanForum.Engine.ViewModels
@model ManageCommentIndex

@{
    ViewBag.Title = "Quản lý comment";
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
<link href="/Content/admin/bootstrap-datetimepicker.min.css" rel="stylesheet" />
@Html.Partial("_partialCommentSearch", Model.Options)

@if (ViewBag.Message != null)
{
    <div class="alert alert-info">
        @ViewBag.Message
    </div>
}
<div class="row">
    <div class="col-md-12">
        @if (Model.ListComment != null && Model.ListComment.Count > 0)
        {
            using (Html.BeginForm())
            {
            <fieldset class="bulk-actions" style="margin-bottom: 20px;">
                <label for="bulkActions" class="filter-label">Tác vụ</label>
                <select class="bulkActions" id="slcBulkAction" name="@Html.NameFor(r=>r.BulkAction)">
                    <option value="0">-- Chọn tác vụ ---</option>
                    <option value="@YanForum.Engine.ViewModels.CommentBulkAction.Delete">Xóa comment</option>
                    <option value="@YanForum.Engine.ViewModels.CommentBulkAction.Approved">Duyệt comment</option>
                </select>
                @Html.Hidden("ReturnUrl")
                <button type="submit" id="commentBulkAction" name="submit.BulkEdit" value="Apply">Apply</button>
            </fieldset>
            
            <table class="table table-bordered table-hover items">
                <thead>
                    <tr>
                        <th scope="col" class="text-center" style="width: 50px;">
                            <input class="selectAll" type="checkbox" value="@Html.NameFor(m => m.ListComment)" /></th>
                        <th>Nội dung</th>
                        <th style="width: 100px;">Ngày đăng</th>
                        <th style="width: 80px;">ContentId</th>
                        <th style="width: 100px;">Người đăng</th>
                        <th style="width: 80px;">Action</th>
                    </tr>
                </thead>
                <tbody>
                    @{var index = 0;}
                    @foreach (var item in Model.ListComment)
                    {
                        <tr>
                            <td class="text-center">
                                <input type="hidden" name="@Html.NameFor(m => m.ListComment[index].Id)" value="@Model.ListComment[index].Id" />
                                <input type="checkbox" value="true" name="@Html.NameFor(m => m.ListComment[index].IsChecked)" />
                            </td>
                            <td>@Html.Raw(item.CommentPost)</td>
                            <td>@string.Format("{0: dd/MM/yyyy}", item.CreateDate)</td>
                            <td>@item.ContentId</td>
                            <td>@item.UserName</td>
                            <td>
                                <a href="javascript:;" data-id="@item.Id" class="i-action btnCommentDelete" title="Xóa comment này"><i class="glyphicon glyphicon-remove"></i></a>
                                @if (item.Approved)
                                {
                                    <a href="javascript:;" class="i-action" title="Comment đã duyệt"><i class="glyphicon glyphicon-ok"></i></a>
                                }
                                else
                                {
                                    <a href="javascript:;" data-id="@item.Id" class="i-action btnApprovedComment" title="Duyệt comment này"><i class="glyphicon glyphicon-thumbs-up"></i></a>
                                }
                            </td>
                        </tr>
                                index++;
                    }
                </tbody>
            </table>
                    if (Model.TotalCount > Model.ListComment.Count)
                    {
                        string url = Url.Action("Index", "CommentAdmin", new { area = "Admin" });
            <div class="col-md-12 text-center">
                <nav>
                    @{Html.RenderAction("Pagging", "Partial", new { area = "", linktext = url + "?search=" + Model.Options.Search + "&createDate=" + Model.Options.CreateDate + "&Approved=" + Model.Options.Approved + "&UserName=" + Model.Options.UserName, totalCount = Model.TotalCount, pageSize = Model.Options.PageSize, pageIndex = Model.Options.PageIndex });}
                </nav>
            </div>
                    }
            }

        }
        else
        {
            <div class="alert alert-info">
                Không tìm thấy kết quả nào!
            </div>
        }
    </div>
</div>

@section scripts
{
    <script src="/Scripts/admin/bootstrap-datetimepicker.min.js"></script>
    <script src="/Scripts/admin/bootstrap-datetimepicker.pt-BR.js"></script>
    <script>
        $(function () {
            $('#datetimepicker').datetimepicker({
                format: 'dd-MM-yyyy'
            });
            $('#ReturnUrl').val(location);            
        })
    </script>
}